package com.clever.mall.mapper;

import com.clever.mall.entity.Address;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface AddressMapper {

    /**
     * 通过用户id和地址id获取地址信息
     * @param aid
     * @return
     */
    Address selectAddressById(@Param("aid") int aid);

    /**
     * 通过用户id获取所有用户地址信息
     * @param uid
     * @return
     */
    List<Address> selectAddressAll(@Param("uid") int uid);

    /**
     * 添加地址
     * @param address
     * @return
     */
    int insertAddress(@Param("address") Address address);

    /**
     * 修改地址
     * @param address
     * @return
     */
    int updateAddress(@Param("address") Address address);

    /**
     * 通过用户id将所有用户地址修改为非默认地址
     * @param uid
     * @return
     */
    int updateAddressIsDefault(@Param("uid") int uid);

    /**
     * 删除地址
     * @param uid
     * @param aid
     * @return
     */
    int delAddress(@Param("uid") int uid, @Param("id") int aid);

    /**
     * 通过用户id获取用户的默认地址
     * @param uid
     * @return
     */
    Address selectAddressDefaultByUserId(@Param("uid") int uid);

    Address selectAddressByUserId(@Param("uid") int uid);

}
